package edu.hawaii.duedates.lender;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.List;
import org.junit.Test;
import com.meterware.httpunit.WebConversation;
import edu.hawaii.duedates.ItemDue;

/**
 * Tests the functionality of the HawaiiStateLibrary class that implements
 * the libraryVault class.
 * 
 * @author Tyler Wolff and Scheller Sanchez
 */
public class TestHawaiiStateLibrary {

  private final boolean useMockLibraries = ("true".equals(System.getProperty("useMockLibraries")));
  
  /**
   * Testing basic object creation within class.
   */
  @Test
  public void testHawaiiStateLibrary() {
    HawaiiStateLibrary hsl = new HawaiiStateLibrary();
    assertEquals("testing name", "Hawaii State Public Library", hsl.getLenderName());
    assertNotNull("hsl not found", hsl);
  }
  
  /**
   * Tests login for the login method. Tests incorrect login info.
   * 
   * @exception Exception if login errors.
   */
  @Test
  public void testBadLogin() throws Exception {

    HawaiiStateLibrary hsl = new HawaiiStateLibrary();
    if (this.useMockLibraries) {
      System.out.println("Skipping HawaiiStateLibrary: testBadLogin");
      assertNotNull("testBadLogin skip", hsl);
    }
    else {
    // incorrect login
      WebConversation conversation = hsl.login("2323", "2334"); //arbitrary numbers
      assertNull("Testing incorrect Login", conversation);
    }
  }
  
  /**
   * Tests the getItemInfo method of the HawaiiStateLibrary class for
   * items out.
   * 
   * @throws Exception if error occurs logging in.
   */
  @Test
  public void testGetItemInfo() throws Exception {
    HawaiiStateLibrary hsl = new HawaiiStateLibrary();

    List<ItemDue> hslInfo = hsl.getItemInfo("2323", "2334");
    assertTrue("Testing incorrect Login", hslInfo.isEmpty());
    
  }
}
